package com.neusoft.controller;

import com.neusoft.po.CommonResult;
import com.neusoft.po.Image;
import com.neusoft.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RefreshScope
@RestController
@RequestMapping("/ImageController")
public class ImageController {

    @Autowired
    private ImageService imageService;

    @GetMapping("/listAllImage")
    public CommonResult<List<Image>> listAllImage() throws Exception {
        List<Image> images = imageService.listAllImage();
        return new CommonResult(200, "success", images);
    }

    @GetMapping("/listImageById/{imgId}")
    public CommonResult<String> listImageById(@PathVariable("imgId") Integer imgId) throws Exception {
        String image = imageService.listImageById(imgId);
        return new CommonResult(200, "success", image);
    }

}
